using System;
using System.Collections.Generic;

namespace OffsetPath
{
    public class ClassAr
    {
        private static ClassAa_OssaSkeletro.SubClassA a = new ClassAa_OssaSkeletro.SubClassA();
        private LinkedList<ClassAa_OssaSkeletro> b = new LinkedList<ClassAa_OssaSkeletro>();
        private PresuntoSkeletroClassAe c;
        private bool d;

        public ClassAr(IEnumerable<ClassAa_OssaSkeletro> A_0, bool A_1)
        {
            this.d = A_1;
            this.MethodA(A_0);
        }

        public void MethodA()
        {
            ClassAa_OssaSkeletro classAa = null;
            for (LinkedListNode<ClassAa_OssaSkeletro> node = this.b.First; node != null; node = node.Next)
            {
                ClassAa_OssaSkeletro aa2 = node.Value;
                if (!aa2.MethodE())
                {
                    classAa = aa2;
                    break;
                }
            }
            if (classAa == null)
            {
                foreach (ClassAa_OssaSkeletro aa3 in this.b)
                {
                    aa3.MethodE(true);
                }
            }
            else
            {
                for (ClassAa_OssaSkeletro aa4 = classAa.Method(); aa4 != classAa; aa4 = aa4.Method())
                {
                    if (aa4.MethodE())
                    {
                        if (aa4.MethodT())
                        {
                            aa4.MethodE(!aa4.MethodN().MethodF());
                        }
                        else
                        {
                            aa4.MethodE(aa4.MethodN().MethodF());
                        }
                    }
                }
            }
        }

        private void MethodA(IEnumerable<ClassAa_OssaSkeletro> A_0)
        {
            foreach (ClassAa_OssaSkeletro aa in this.b)
            {
                aa.MethodA(a, null);
                aa.MethodB((ClassAr) null);
            }
            this.b.Clear();
            foreach (ClassAa_OssaSkeletro aa2 in A_0)
            {
                LinkedListNode<ClassAa_OssaSkeletro> node = this.b.AddLast(aa2);
                aa2.MethodA(a, node);
            }
            if (this.b.Count != 0)
            {
                for (LinkedListNode<ClassAa_OssaSkeletro> node2 = this.b.First; node2 != null; node2 = node2.Next)
                {
                    ClassAa_OssaSkeletro aa3 = node2.Value;
                    LinkedListNode<ClassAa_OssaSkeletro> previous = node2.Previous;
                    if (previous == null)
                    {
                        previous = this.b.Last;
                    }
                    ClassAa_OssaSkeletro aa4 = previous.Value;
                    aa4.MethodA(aa3);
                    aa3.MethodB(aa4);
                    aa3.MethodB(this);
                }
            }
        }

        public void MethodA(ClassAa_OssaSkeletro A_0)
        {
            if (this.MethodD() > 3)
            {
                throw new InvalidOperationException();
            }
            Dictionary<SkeletroBaseLineaClasseI, bool> dictionary = new Dictionary<SkeletroBaseLineaClasseI, bool>();
            foreach (ClassAa_OssaSkeletro aa in this.b)
            {
                aa.MethodB((ClassAr) null);
                aa.MethodC(A_0);
                aa.MethodA(a, null);
                dictionary[aa.MethodW()] = true;
                dictionary[aa.MethodC()] = true;
            }
            foreach (KeyValuePair<SkeletroBaseLineaClasseI, bool> pair in dictionary)
            {
                pair.Key.MethodD(A_0);
            }
            this.b.Clear();
            LinkedListNode<ClassAa_OssaSkeletro> node = this.b.AddLast(A_0);
            A_0.MethodA(a, node);
            A_0.MethodB(A_0);
            A_0.MethodA(A_0);
            A_0.MethodB(this);
        }

        public void MethodA(PresuntoSkeletroClassAe A_0)
        {
            this.c = A_0;
        }

        public void MethodA(ClassAa_OssaSkeletro A_0, ClassAa_OssaSkeletro A_1)
        {
            if (((A_0 == null) || (A_1 == null)) || (((A_1 == A_0) || (A_1.MethodS() != null)) || (A_0.MethodS() != this)))
            {
                throw new ArgumentException();
            }
            LinkedListNode<ClassAa_OssaSkeletro> node = A_0.MethodA(a) as LinkedListNode<ClassAa_OssaSkeletro>;
            if (node == null)
            {
                throw new ArgumentException();
            }
            LinkedListNode<ClassAa_OssaSkeletro> node2 = this.b.AddAfter(node, A_1);
            A_1.MethodA(a, node2);
            ClassAa_OssaSkeletro classAa = A_0.Method();
            A_0.MethodA(A_1);
            A_1.MethodA(classAa);
            classAa.MethodB(A_1);
            A_1.MethodB(A_0);
            A_1.MethodB(this);
        }

        public bool MethodA(ClassAa_OssaSkeletro A_0, ClassAa_OssaSkeletro A_1, out ClassAa_OssaSkeletro A_2, out ClassAa_OssaSkeletro A_3)
        {
            if ((A_0 == null) || (A_1 == null))
            {
                throw new ArgumentException();
            }
            ClassAa_OssaSkeletro classAa = A_0.MethodA(0);
            if (classAa.MethodS() != this)
            {
                throw new InvalidOperationException();
            }
            A_2 = null;
            A_3 = null;
            PresuntoSkeletroClassAe classAe = this.MethodE();
            ClassAa_OssaSkeletro aa2 = A_1;
            if (aa2 == null)
            {
                return false;
            }
            ClassAr classAr = aa2.MethodS();
            A_2 = new ClassAa_OssaSkeletro(A_0.MethodJ(), A_0.MethodC(), aa2.MethodW(), true);
            A_3 = new ClassAa_OssaSkeletro(A_0.MethodJ(), aa2.MethodW(), A_0.MethodW(), true);
            if (A_0.MethodT())
            {
                A_2.MethodD(A_0.MethodH());
            }
            if (A_0.MethodT())
            {
                A_3.MethodD(A_0.MethodH());
            }
            if (!A_2.MethodF())
            {
                A_2.MethodE(true);
            }
            if (!A_3.MethodF())
            {
                A_3.MethodE(true);
            }
            this.MethodA(classAa, A_2, A_3, classAr, aa2);
            classAe.MethodB(classAr);
            classAe.MethodC();
            classAa.MethodB((ClassAr) null);
            classAa.MethodB((ClassAa_OssaSkeletro) null);
            classAa.MethodA((ClassAa_OssaSkeletro) null);
            return true;
        }

        private void MethodA(ClassAa_OssaSkeletro A_0, ClassAa_OssaSkeletro A_1, ClassAa_OssaSkeletro A_2, ClassAr A_3, ClassAa_OssaSkeletro A_4)
        {
            List<ClassAa_OssaSkeletro> list = new List<ClassAa_OssaSkeletro> {
                                             A_1
                                         };
            for (ClassAa_OssaSkeletro classAa = A_4.Method(); classAa != A_4; classAa = classAa.Method())
            {
                list.Add(classAa);
                if (list.Count >= (this.MethodD() + A_3.MethodD()))
                {
                    throw new CustomException("Merge LAV encounter infinite loop.");
                }
            }
            list.Add(A_4);
            list.Add(A_2);
            for (ClassAa_OssaSkeletro aa2 = A_0.Method(); aa2 != A_0; aa2 = aa2.Method())
            {
                list.Add(aa2);
                if (list.Count > ((this.MethodD() + A_3.MethodD()) + 1))
                {
                    throw new CustomException("Merge LAV encounter infinite loop.");
                }
            }
            if (list.Count != ((this.MethodD() + A_3.MethodD()) + 1))
            {
                throw new CustomException("Break LAV error: invalid vertex count.");
            }
            if (!A_3.MethodB())
            {
                this.d = false;
            }
            this.MethodA(list);
        }

        private void MethodA(ClassAa_OssaSkeletro A_0, ClassAa_OssaSkeletro A_1, ClassAa_OssaSkeletro A_2, ClassAa_OssaSkeletro A_3, out ClassAr A_4, out ClassAr A_5)
        {
            A_4 = null;
            A_5 = null;
            List<ClassAa_OssaSkeletro> list = new List<ClassAa_OssaSkeletro>();
            for (ClassAa_OssaSkeletro classAa = A_3.Method(); classAa != A_0; classAa = classAa.Method())
            {
                list.Add(classAa);
                if (list.Count >= this.MethodD())
                {
                    throw new CustomException("Break LAV encounter infinite loop.");
                }
            }
            list.Add(A_1);
            List<ClassAa_OssaSkeletro> list2 = new List<ClassAa_OssaSkeletro> {
                                              A_2
                                          };
            for (ClassAa_OssaSkeletro aa2 = A_0.Method(); aa2 != A_3; aa2 = aa2.Method())
            {
                list2.Add(aa2);
                if (list2.Count >= this.MethodD())
                {
                    throw new CustomException("Break LAV encounter infinite loop.");
                }
            }
            list2.Add(A_3);
            if ((list.Count + list2.Count) != (this.MethodD() + 1))
            {
                throw new CustomException("Break LAV error: invalid vertex count.");
            }
            A_4 = new ClassAr(list, this.MethodB());
            A_5 = new ClassAr(list2, this.MethodB());
        }

        public bool MethodA(ClassAa_OssaSkeletro A_0, ClassAa_OssaSkeletro A_1, out ClassAa_OssaSkeletro A_2, out ClassAa_OssaSkeletro A_3, out ClassAr A_4, out ClassAr A_5)
        {
            if ((A_0 == null) || (A_1 == null))
            {
                throw new ArgumentException();
            }
            ClassAa_OssaSkeletro classAa = A_0.MethodA(0);
            if (classAa.MethodS() != this)
            {
                throw new InvalidOperationException();
            }
            A_2 = null;
            A_3 = null;
            A_4 = null;
            A_5 = null;
            PresuntoSkeletroClassAe classAe = this.MethodE();
            ClassAa_OssaSkeletro aa2 = A_1;
            if (aa2 == null)
            {
                throw new CustomException("Can not find split edge in LAV.");
            }
            A_2 = new ClassAa_OssaSkeletro(A_0.MethodJ(), A_0.MethodC(), aa2.MethodW(), true);
            A_3 = new ClassAa_OssaSkeletro(A_0.MethodJ(), aa2.MethodW(), A_0.MethodW(), true);
            if (A_0.MethodT())
            {
                A_2.MethodD(A_0.MethodH());
            }
            if (A_0.MethodT())
            {
                A_3.MethodD(A_0.MethodH());
            }
            if (!A_2.MethodF())
            {
                A_2.MethodE(true);
            }
            if (!A_3.MethodF())
            {
                A_3.MethodE(true);
            }
            this.MethodA(classAa, A_2, A_3, aa2, out A_4, out A_5);
            classAe.MethodB(this);
            classAe.MethodA(A_4);
            classAe.MethodA(A_5);
            classAa.MethodB((ClassAr) null);
            classAa.MethodB((ClassAa_OssaSkeletro) null);
            classAa.MethodA((ClassAa_OssaSkeletro) null);
            return true;
        }

        public bool MethodB()
        {
            return this.d;
        }

        public void MethodB(ClassAa_OssaSkeletro A_0)
        {
            if ((A_0 == null) || (A_0.MethodS() != this))
            {
                throw new ArgumentException();
            }
            LinkedListNode<ClassAa_OssaSkeletro> node = A_0.MethodA(a) as LinkedListNode<ClassAa_OssaSkeletro>;
            this.b.Remove(node);
            A_0.MethodA(a, null);
            ClassAa_OssaSkeletro classAa = A_0.MethodN();
            ClassAa_OssaSkeletro aa2 = A_0.Method();
            classAa.MethodA(aa2);
            aa2.MethodB(classAa);
            A_0.MethodB((ClassAr) null);
            A_0.MethodB((ClassAa_OssaSkeletro) null);
            A_0.MethodA((ClassAa_OssaSkeletro) null);
            A_0.MethodV();
        }

        public void MethodB(ClassAa_OssaSkeletro A_0, ClassAa_OssaSkeletro A_1)
        {
            if (((A_0 == null) || (A_1 == null)) || (((A_0 == A_1) || (A_1.MethodS() != null)) || (A_0.MethodS() != this)))
            {
                throw new ArgumentException();
            }
            LinkedListNode<ClassAa_OssaSkeletro> node = A_0.MethodA(a) as LinkedListNode<ClassAa_OssaSkeletro>;
            if (node == null)
            {
                throw new ArgumentException();
            }
            LinkedListNode<ClassAa_OssaSkeletro> node2 = this.b.AddBefore(node, A_1);
            A_1.MethodA(a, node2);
            ClassAa_OssaSkeletro classAa = A_0.MethodN();
            A_0.MethodB(A_1);
            A_1.MethodB(classAa);
            classAa.MethodA(A_1);
            A_1.MethodA(A_0);
            A_1.MethodB(this);
        }

        public IEnumerable<ClassAa_OssaSkeletro> MethodC()
        {
            return this.b;
        }

        public int MethodD()
        {
            return this.b.Count;
        }

        public PresuntoSkeletroClassAe MethodE()
        {
            return this.c;
        }
    }
}

